//=============================================================================
// Window_StatCompare
//=============================================================================
Window_StatCompare.prototype.initialize = function(wx, wy, ww, wh) {
    Window_Base.prototype.initialize.call(this, wx, wy, ww, wh);
    this._actor = null;
    this._tempActor = null;
    this.refresh();
    this.setSmallerFont();
};


Window_StatCompare.prototype.createWidths = function() {
      this._paramNameWidth = this.textWidth(TextManager.param(0));
      this._paramValueWidth = this.textWidth('0000');
      this._arrowWidth = this.textWidth('\u2192') + this.textWidth(' ');
      this._bonusValueWidth = this.textWidth('000') + this.textWidth('(+)');
};

Window_StatCompare.prototype.refresh = function () {
    this.contents.clear();
    if (!this._actor) return;
    let paramIds = []
    paramIds = [0, 1, 2, 3, 4, 5, 6];
    for (var i = 0; i < 2; ++i) {
        this.drawItem(0, this.lineHeight() * i, paramIds[i]);
    }
    // 体力：
    this.changeTextColor(this.systemColor());
    this.drawText("体力上限", this.textPadding(), this.lineHeight() * i, this._paramNameWidth);
    this.resetTextColor();
    this.drawText(Yanfly.Util.toGroup(this._actor.maxTp()),
        this.contents.width - this.textPadding() - (this._paramValueWidth * 2 + this._arrowWidth + this._bonusValueWidth),
        this.lineHeight() * i, this._paramValueWidth, 'right');
    if (!!this._tempActor) {
        this.drawRightArrow(this.lineHeight() * i);
        var diffvalue = this._tempActor.maxTp() - this._actor.maxTp();
        this.changeTextColor(this.paramchangeTextColor(diffvalue));
        this.drawText(Yanfly.Util.toGroup(this._tempActor.maxTp()),
            this.contents.width - this.textPadding() - (this._paramValueWidth + this._bonusValueWidth),
            this.lineHeight() * i, this._paramValueWidth, 'right');
        if (diffvalue !== 0) {
            this.changeTextColor(this.paramchangeTextColor(diffvalue));
            var text = Yanfly.Util.toGroup(diffvalue);
            if (diffvalue > 0) {
                text = ' (+' + text + ')';
            } else {
                text = ' (' + text + ')';
            }
            this.drawText(text, 
                this.contents.width - this.textPadding() - this._bonusValueWidth, 
                this.lineHeight() * i, this._bonusValueWidth, 'left');
        }
    }
    for (var i = 2; i < paramIds.length; ++i) {
        this.drawItem(0, this.lineHeight() * (i+1), paramIds[i]);
    }
    /*
    for (var i = 0; i < 3; ++i) {
        this.drawElement(0, this.lineHeight() * (i + 9), i + 1);
    }*/
};


Window_StatCompare.prototype.drawItem = function(x, y, paramId) {
    this.drawParamName(y, paramId);
    this.drawCurrentParam(y, paramId);
    if (!this._tempActor) return;
    this.drawRightArrow(y);
    this.drawNewParam(y, paramId);
    this.drawParamDifference(y, paramId);
};

Window_StatCompare.prototype.drawParamName = function(y, paramId) {
    var x = this.textPadding();
    this.changeTextColor(this.systemColor());
    this.drawText(TextManager.param(paramId), x, y, this._paramNameWidth);
};

// 绘制属性抗性变化
Window_StatCompare.prototype.drawElement = function(x, y, eleId) {
    this.drawElementName(eleId, this.textPadding(), y);
    this.drawCurrentElement(y, eleId);
    if (!this._tempActor) return;
    this.drawRightArrow(y);
    this.drawNewElement(y, eleId);
};

Window_StatCompare.prototype.drawCurrentElement = function(y, eleId) {
    var x = this.contents.width;
    x -= this.textWidth('抗100%') * 2 + this._arrowWidth + this._bonusValueWidth;
    this.drawElementData(this._actor, eleId, x, y);
};

Window_StatCompare.prototype.drawNewElement = function(y, eleId) {
    var x = this.contents.width + this.textPadding();
    x -= this.textWidth('抗100%');
    this.drawElementData(this._tempActor, eleId, x, y);

};